package org.jingouzhui.domain.strategy.service.rule.chain.impl;

import lombok.extern.slf4j.Slf4j;
import org.jingouzhui.domain.strategy.service.armory.IStrategyDispatch;
import org.jingouzhui.domain.strategy.service.rule.chain.AbstractLogicChain;
import org.jingouzhui.domain.strategy.service.rule.chain.factory.DefaultLogicChainFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @description: 兜底抽奖责任链，其他都未命中的话走默认的抽奖流程
 * @author: jingouzhui
 * @date: 2025/4/29 13:36
 */
@Component("default")
@Slf4j
public class DefaultLogicChain extends AbstractLogicChain {

    @Resource
    private IStrategyDispatch strategyDispatch;

    @Override
    protected String ruleModel() {
        return DefaultLogicChainFactory.LogicModel.RULE_DEFAULT.getCode();
    }

    @Override
    public DefaultLogicChainFactory.StrategyAwardVO logic(String userId, Long strategyId) {
        log.info("责任链-默认抽奖开始处理抽奖流程，userId：{}，strategyId：{}",userId,strategyId);
        Integer awardId = strategyDispatch.getRandomAwardId(strategyId);
        return DefaultLogicChainFactory.StrategyAwardVO
                .builder()
                .awardId(awardId)
                .logicModel(ruleModel())
                .build();
    }
}
